package com.cinema.dao;

import java.util.List;

/**
 * 售票数据访问接口
 */
public interface TicketDao {
    
    /**
     * 售票
     */
    void sellTicket(String scheduleId, int row, int col, String phone, String operatorId);
    
    /**
     * 检查座位是否已售
     */
    boolean isSeatOccupied(String scheduleId, int row, int col);
    
    /**
     * 获取排片的座位状态
     */
    boolean[][] getSeatStatus(String scheduleId, int rows, int cols);
    
    /**
     * 获取排片的售票记录
     */
    List<TicketRecord> getTicketRecords(String scheduleId);
    
    /**
     * 获取座位统计信息
     */
    SeatStatistics getSeatStatistics(String scheduleId);
    
    /**
     * 售票记录
     */
    class TicketRecord {
        private final int row;
        private final int col;
        private final String phone;
        private final String operatorId;
        private final String soldAt;
        
        public TicketRecord(int row, int col, String phone, String operatorId, String soldAt) {
            this.row = row;
            this.col = col;
            this.phone = phone;
            this.operatorId = operatorId;
            this.soldAt = soldAt;
        }
        
        public int getRow() { return row; }
        public int getCol() { return col; }
        public String getPhone() { return phone; }
        public String getOperatorId() { return operatorId; }
        public String getSoldAt() { return soldAt; }
    }
    
    /**
     * 座位统计信息
     */
    class SeatStatistics {
        private final int totalSeats;
        private final int occupiedSeats;
        private final int availableSeats;
        
        public SeatStatistics(int totalSeats, int occupiedSeats) {
            this.totalSeats = totalSeats;
            this.occupiedSeats = occupiedSeats;
            this.availableSeats = totalSeats - occupiedSeats;
        }
        
        public int getTotalSeats() { return totalSeats; }
        public int getOccupiedSeats() { return occupiedSeats; }
        public int getAvailableSeats() { return availableSeats; }
        public double getOccupancyRate() { 
            return totalSeats > 0 ? (double) occupiedSeats / totalSeats : 0.0; 
        }
    }
} 